const path = require('path')
const common = require('./webpack.common')
const { merge } = require('webpack-merge');
const Webpack = require('webpack');


module.exports = merge(common, {
  mode: 'development',
  devtool: 'eval-cheap-module-source-map',
  devServer: {
    hot: true,
    inline: true,
    hotOnly: true,  //当编译失败时，不刷新页面
    overlay: true,  //用来在编译出错的时候，在浏览器页面上显示错误
    contentBase: path.join(__dirname, "public"),
    port: 8080,
    proxy: {
      '/api': {
        target: 'https://api.github.com/',
        // 转发路径重写
        pathRewrite: {
          '^/api': ''
        },
        // 不能使用 本地的主机名 去请求 需要被代理 api
        changeOrigin: true
      }
    }
  },
  plugins: [
    new Webpack.HotModuleReplacementPlugin(),
  ]
})